package com.pni.game.cards.deck;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Stack;

import com.pni.game.cards.Card;

public class DeckImpl extends Deck {
	
	/**
	 * Stack to represent a deck of cards;
	 */
	private Stack<Card> cards;
	
	/**
	 *	Creates an empty deck of cards.  This is package protected, please use factory methods to create Deck objects.
	 */
	/*package*/ DeckImpl(){
		this.cards = new Stack<Card>();
	}

	public void addCard(Card card) {
		cards.push(card);
		
	}

	public Card takeCard() {
		return cards.pop();
	}

	public Collection<Card> takeAllCards() {
		if(cards.isEmpty()){
			return null;
		}
		Collection<Card> cardsToReturn = cards.subList(0, cards.size());
		cards.removeAll(cardsToReturn);
		return cardsToReturn;
	}

	public Collection<Card> getCards() {
		return cards;
	}

	public int numberOfCards() {
		return cards.size();
	}

	public boolean isEmpty() {
		return cards.empty();
	}

	public void shuffleCards() {
		Collections.shuffle(cards);
		
	}

}
